import Components from 'unplugin-vue-components/vite';
import {ElementPlusResolver} from 'unplugin-vue-components/resolvers';
import IconsResolver from 'unplugin-icons/resolver';

export default (path: any) => {
    return Components({
        // 要搜索组件的目录的相对路径
        dirs: ['src/components'],
        // 组件的有效文件扩展名
        extensions: ['vue', 'md'],
        // 搜索子目录
        deep: true,
        include: [/\.vue$/, /\.vue\?vue/],
        // 生成自定义 `auto-components.d.ts` 全局声明
        dts: 'src/types/auto-components.d.ts',
        exclude: [/[\\/]node_modules[\\/]/],
        resolvers: [
            // 自动导入 Element Plus 组件
            ElementPlusResolver(),
            // 自动注册图标组件
            IconsResolver({
                enabledCollections: ['ep']
            })
        ]
    });
};
